#Include <FindText>
#Include ..\const\LightningBuyConst.ahk
#Include ..\const\LightningConst.ahk
#Include ..\const\ClientConstant.ahk
#Include ..\utils\KeyboardUtils.ahk
#Include ..\utils\HwndUtils.ahk
#Include ..\service_api\CommonService.ahk

class CommonServiceImpl extends CommonService{
    ; 查找证劵代码,找到了,就输入对应的 证券代码
     findSecurityCode(input_code){
        ; 剪切版内容
        A_Clipboard := ""
        while A_Clipboard != input_code
        {
            t1:=A_TickCount, Text:=X:=Y:=""
                    Text := LightningConst.SECURITY_CODE
                    ok:=FindText(&X:="wait", &Y:=ClientConstant.SCREEN_QUERY_TIME, 0,0,0,0,0,0,Text)  ; 等待3秒等图像出现\
                    if (ok)
                    {
                       A_Clipboard := ""
                       FindText().Click(X+100, Y, "L")
                       KeyboardUtils.selectAll()
                       KeyboardUtils.copy()
                       SendInput input_code
                       ; 等待剪切板内容更新
                       ClipWait
                       ;Msgbox "剪切版中的内容为 " . A_Clipboard
                    }else{
                        TipUtils.tip("没有找到代码！")
                    }
        }
    }
    ; 查找提示的窗口信息
     findTipWindow(){
        ; 循环 5 次

        t1:=A_TickCount, Text:=X:=Y:=""
        Text := LightningConst.TIP_WINDOW
        ok:=FindText(&X:="wait", &Y:=ClientConstant.SCREEN_QUERY_TIME, 0,0,0,0,0,0,Text)  ; 等待3秒等图像出现\
        if (ok){
           FindText().Click(X, Y, "L")
           KeyboardUtils.enter()
        }
        Text:=LightningConst.TIP_WINDOW_NOT_FORCE
        ok:=FindText(&X:="wait", &Y:=3, 0,0,0,0,0,0,Text)  ; 等待3秒等图像出现\
        if (ok){
           FindText().Click(X, Y, "L")
           KeyboardUtils.enter()
        }


    }

    minWindow(){
        HwndUtils.activateWindow()
        t1:=A_TickCount, Text:=X:=Y:=""
        ; 东方财富证券的 窗口的 logo
        Text:="|<>*193$118.0J07U03U2w70706000Q03I0Q00C0QMQ0w0tzstnURsTzw0s1hjvs3lUQ1rQTiUS03zzaq7C0731k3RXwv3n03k0PMQs0Q0r1zzzbwCQ0D01hjkvz3bQ0C0wxltk0xw6qz3UQCRkTzzDr7bU3kQPPwC1ktr0DD1yw0S0D1lhhkvy3bS1sSDnkBq0w76qr000CRkDzwzT1rQ3UQPTQQQstr1j3nvs7RkC1lzxlllnbQ0sCDDUtnUs71tr7zzCRk3UsFy3bC7UQ7qQQQQxr0C3U7kRwQQzkv7lllVrQ1ny0D03k3Vy7CC7zy6zyD7k0s0000000000000000001000000000000000000U"
        ok:=FindText(&X:="wait", &Y:=3, 0,0,0,0,0,0,Text)  ; 等待3秒等图像出现\
        if (ok){
           FindText().Click(X, Y, "L")
           KeyboardUtils.pressF12()
           KeyboardUtils.enter()
        }
    }
}